// pages/evt/evt.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    //开始时间
    stime :0,
    //结束时间
    etime:0,
    //默认颜色
    color:'#333'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  clickFun(evt){
    console.log(evt);
    
    console.log(3333);
  },
  subclickFun(){
    console.log(666);
  },
  estartFun(){
    console.log('start');
    let stime =new Date().getTime();
    this.data.stime = stime;
  },
  endFun(){
    console.log('end');
    let etime =new Date().getTime();
    let difftime = etime -this.data.stime;
    console.log(difftime);

    let color = this.retColor(difftime);
    this.setData({
      color
    })
  },
  retColor(num){
    let n = Math.floor(num / 1000);

    let color = '#000';
    if(n < 1){
      color = '#ff0000';
    } else if (n < 2){
      color = '#00ff00';
    } else if (n < 4) {
      color = '#0000ff';
    } else if (n < 5) {
      color = '#f60';
    } else if (n < 6) {
      color = 'green';
    }else{
      color = '#ccc';
    }

    return color;
  }
})